package domain.advertisement;

import technicalservices.database.PersistanseStorage;
import domain.users.User;


public class AccountBalance {
	private double amount =0 ;
	
	public AccountBalance() {
	}

	public double getFounds(AdDatabase ads, User advertiser) {
		double totalViewCost = 0, totalClickCost = 0;
		
		for (Ad ad : ads.getAds()) {
			if(ad.getAdvertiser() == advertiser) {
				totalClickCost += ad.getScheme().getClicks() * ad.getScheme().getType().getCostClick();
				totalViewCost += ad.getScheme().getViews() * ad.getScheme().getType().getCostView();
			}
		}
		
		return amount - (totalViewCost + totalClickCost);
	}
	
	private void initAmount(User advertiser) {
		//PersistanseStorage.getInstance().getAdAmount(advertiser);
	}

	public double getAmount() {
		return amount;
	}

	public void setAmount(double amount) {
		this.amount += amount;
	}

}
